#!/usr/bin/perl

require "./mailadmin-lib.pl";
&ReadParse();

my ($vols, $err_msg, $dirpath, $mntroot, $type);

$mntroot = &get_mnt_root();

$dirpath = $in{'dirpath'};
$type = $in{'req_udata'};

unless ($dirpath)
{
    $err_msg = $text{'err_msg_no_loadout_dir'};
    goto ERROR_OUT;
}

if ($type ne 'nouserdata')
{
    $type = 'userdata';
}

$dirpath = $mntroot . $dirpath;

if (! (-d $dirpath) )
{
    $err_msg = $text{'err_msg_loadout_dir_not_path'};
    goto ERROR_OUT;
}

&mail_conf_loadout($type, $dirpath);

&redirect("maildir_edit.cgi");
exit(0);

ERROR_OUT:;
my (@headp, @footp);
@headp = ($text{'error'}, "");
@footp = ("maildir_edit.cgi", $text{'back_maildir'});
&mail_error(\@headp, \@footp, $text{'err_title_load_maildir_conf'}, $err_msg);
